-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API to gracefully cancel a controller #4136
Add API to gracefully cancel a controller #4136
Conversation
87c468f
to
52327c8
Compare
52327c8
to
1d22c51
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4136 +/- ##
==========================================
+ Coverage 89.49% 89.86% +0.37%
==========================================
Files 431 432 +1
Lines 19555 19411 -144
==========================================
- Hits 17500 17443 -57
+ Misses 2055 1968 -87 ☔ View full report in Codecov by Sentry. |
I think having the cancel state projected back to the Or possibly even have separate Then, the So all in all, I like your design, but I think we an do it a little bit better with addresses the problem of the controller knowing when we're back outside of the non-canceled state for normal operations & adding a timeout in case a plugin isn't properly implemented |
@SteveMacenski which controller is the easiest to modify with this new API? I was thinking about the pure pursuit controller but that one doesn't have decelleration limits so I don't know how fast to brake. How is the acceleration determined? |
Which ever one you like - I think DWB is the only one with explicit decel/accel parameters right now. MPPI will have it before EOY, but not its current state. RPP is a pure geometric approach, so there's not really any dynamic modeling (right, its just following a carrot). We have some constraints on speed based on some heuristic functions, but that's also not dynamics based, its situational. |
1d22c51
to
93f08e9
Compare
@Rayman, your PR has failed to build. Please check CI outputs and resolve issues. |
@Rayman anything I need to review? Or still working on it 😄 |
93f08e9
to
197eb53
Compare
@Rayman, your PR has failed to build. Please check CI outputs and resolve issues. |
Yes sorry I'm still working on it. I've modified the RPP controller to add a cancel_decelleration parameter that shows how to use the new API. Is this in line with the design of the controller? I thought that one was the easiest to modify. Most controllers don't have acceleration limits, only the DWB. But that one is quite complicated with the critics so I didn't know how to modify it to support cancellation. I've also adressed one of your review comments. Last thing to do is add some unit tests probably. |
197eb53
to
d5571c9
Compare
@Rayman, your PR has failed to build. Please check CI outputs and resolve issues. |
...pure_pursuit_controller/include/nav2_regulated_pure_pursuit_controller/parameter_handler.hpp
Outdated
Show resolved
Hide resolved
nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp
Outdated
Show resolved
Hide resolved
nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp
Outdated
Show resolved
Hide resolved
nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp
Show resolved
Hide resolved
nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp
Outdated
Show resolved
Hide resolved
Generally looks good to me! |
d5571c9
to
a80350f
Compare
@Rayman, your PR has failed to build. Please check CI outputs and resolve issues. |
I don't understand the CI failure. I didn't edit any |
@Rayman we're in a weird state due to the rolling transition to 24.04. I'll plan to look into it in more detail on Friday, but for now, if you tell me it works and you tested it, I'd trust that assuming the other checks look good |
nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp
Outdated
Show resolved
Hide resolved
@Rayman, your PR has failed to build. Please check CI outputs and resolve issues. |
I've tested this only in simulation for now. I'll test this on a robot in the next coming weeks but I need some more parts to be ready for that. I'll send this PR also to a collegue to review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
This now works in simulation for the pure pursuit and our own controller. So for me that's good enough 🙂. I don't think the physical interfaces of the robot will influence this behavior. But I'll leave that up to @SteveMacenski
RCLCPP_INFO_THROTTLE( | ||
get_logger(), | ||
*get_clock(), 1000, | ||
"Goal was canceled. Requesting controller to stop robot gracefully."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: this is an implementation detail. "Waiting for the controller to finish cancellation"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, publishZeroVelocity();
enforces a stop, so this is the only option 😄. You can leave it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, @Rayman can you make that string update? Then I can merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Sim is good enough for me - yal know what you're doing. Feel free to implement other controllers if you like (or contribute your controller here) 😉 |
Signed-off-by: Ramon Wijnands <[email protected]>
Signed-off-by: Ramon Wijnands <[email protected]>
Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]>
b07b0a3
to
be2e9d2
Compare
Thanks @Rayman ! |
Nice work, I haven't tested it but reading on the changes, 2 questions:
|
You could set the deceleration to something insanely high to in effect disable, but this is a good point, it should be an option. We can make a param pretty easily that'll bypass this if needed. I filed a ticket #4238 for record keeping
Nope, only on cancel:
|
All good short term then! |
* Add API to gracefully cancel a controller Signed-off-by: Ramon Wijnands <[email protected]> * Add `cancel_deceleration` to RegulatedPurePursuitController Signed-off-by: Ramon Wijnands <[email protected]> * Update nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> --------- Signed-off-by: Ramon Wijnands <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> Co-authored-by: Steve Macenski <[email protected]>
* Add API to gracefully cancel a controller Signed-off-by: Ramon Wijnands <[email protected]> * Add `cancel_deceleration` to RegulatedPurePursuitController Signed-off-by: Ramon Wijnands <[email protected]> * Update nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> --------- Signed-off-by: Ramon Wijnands <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> Co-authored-by: Steve Macenski <[email protected]>
* Add API to gracefully cancel a controller Signed-off-by: Ramon Wijnands <[email protected]> * Add `cancel_deceleration` to RegulatedPurePursuitController Signed-off-by: Ramon Wijnands <[email protected]> * Update nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> --------- Signed-off-by: Ramon Wijnands <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: enricosutera <[email protected]>
* Add API to gracefully cancel a controller Signed-off-by: Ramon Wijnands <[email protected]> * Add `cancel_deceleration` to RegulatedPurePursuitController Signed-off-by: Ramon Wijnands <[email protected]> * Update nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> --------- Signed-off-by: Ramon Wijnands <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> Co-authored-by: Steve Macenski <[email protected]>
* Add API to gracefully cancel a controller Signed-off-by: Ramon Wijnands <[email protected]> * Add `cancel_deceleration` to RegulatedPurePursuitController Signed-off-by: Ramon Wijnands <[email protected]> * Update nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> --------- Signed-off-by: Ramon Wijnands <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> Co-authored-by: Steve Macenski <[email protected]>
* Add API to gracefully cancel a controller Signed-off-by: Ramon Wijnands <[email protected]> * Add `cancel_deceleration` to RegulatedPurePursuitController Signed-off-by: Ramon Wijnands <[email protected]> * Update nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> --------- Signed-off-by: Ramon Wijnands <[email protected]> Signed-off-by: Ramon Wijnands <[email protected]> Co-authored-by: Steve Macenski <[email protected]>
Basic Info
Description of contribution in a few bullet points
Ability to let controllers handle cancelations gracefully. See the discussion at #4033.
I'm opening this PR for a first review of the API. I've added gracefull cancellation to one of our in-house controllers and tested that this API is sufficient. I hope the API fits the design of the core APIs.
Description of documentation updates required from your changes
Future work that may be required in bullet points
For Maintainers: